package main

import (
	"encoding/gob"
	"fmt"
	"net"
	"rpc_client_demo/client"
)

type User struct {
	Name string
	Age  int
}

func main() {
	gob.Register(User{})
	//连接
	conn,err := net.Dial("tcp",":8000")
	if err != nil {
		panic(err)
	}
	//创建客户端对象
	cli := client.NewMyClient(conn)
	var queryUser func(uid int) (User, int)
	cli.CallRpc("queryUser",&queryUser)
	ret,code := queryUser(100)
	if code != 0 {
		fmt.Println("rpc调用错误")
	}
	if ret == (User{}) {
		fmt.Println("用户不存在")
		return
	}
	fmt.Println(ret)
}
